﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using TarreOA.TarreOABLL;
using TarreOA.TarreOAModels;

public partial class PublicCommunication_FindLinkManByUnitName : System.Web.UI.Page
{
    private string linkManUnitName;

    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        linkManUnitName = Request.Form.Get(this.TxtLinkManUnitName.ClientID);
        this.DataList_DataTable();
        ViewState["lm_uname"] = linkManUnitName;
    }

    protected void DataList_DataTable()
    {
        PublicCommunicationGroupLinkManService pcgLmService = new PublicCommunicationGroupLinkManService();
        List<PublicCommunicationGroupLinkMantb> list = pcgLmService.findByLinkManUnitName(linkManUnitName);
        if (list != null && list.Count > 0)
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("GroupLinkManId", typeof(string));
            dt.Columns.Add("GroupLinkManName", typeof(string));
            dt.Columns.Add("GroupLinkManHandset", typeof(string));
            dt.Columns.Add("GroupLinkManSec", typeof(string));
            dt.Columns.Add("GroupLinkManUnitTelephone", typeof(string));
            dt.Columns.Add("GroupLinkManEmail", typeof(string));
            dt.Columns.Add("GroupLinkManSmallHand", typeof(string));
            foreach (PublicCommunicationGroupLinkMantb pcgLinkMan in list)
            {
                DataRow dr = dt.NewRow();
                dr["GroupLinkManId"] = pcgLinkMan.GroupLinkManId.ToString();
                dr["GroupLinkManName"] = pcgLinkMan.GroupLinkManName;
                dr["GroupLinkManHandset"] = pcgLinkMan.GroupLinkManHandset;
                dr["GroupLinkManSec"] = pcgLinkMan.GroupLinkManSec == 0 ? "男" : "女";
                dr["GroupLinkManUnitTelephone"] = pcgLinkMan.GroupLinkManUnitTelephone;
                dr["GroupLinkManEmail"] = pcgLinkMan.GroupLinkManEmail;
                dr["GroupLinkManSmallHand"] = pcgLinkMan.GroupLinkManMsn;
                dt.Rows.Add(dr);
            }
            this.DataList1.DataSource = dt.DefaultView;
            this.DataList1.DataBind();
        }
        else
        {
            this.DataList1.DataSource = null;
            this.DataList1.DataBind();
        }
    }
    protected void DataList1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
        {
            string pcglm_id = ((HtmlInputHidden)e.Item.FindControl("HidLinkManId")).Value;
            ((HyperLink)e.Item.FindControl("HylInfo")).Attributes.Add("onclick", "return openLinkManDialogWindow(" + pcglm_id + ")");
        }
    }

}
